home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / thor / bulkmail.thor < prev    next >
Text File  |  1996-11-10  |  4KB  |  134 lines

  1. /* BulkMail.thor - Neil Bothwick - v1.0 (8/1/96)           */
  2. /* Searches the User database for Comments containing the  */
  3. /* supplied string, and then sends each match a copy of    */
  4. /* the currently selected EMail event.                     */
  5.  
  6.  
  7. /* Parts of this script have been 'borrowed' from    */
  8. /* SelectedReply2Enter.thor by Troels Walsted Hansen */
  9.  
  10.  
  11. options results
  12.  
  13. EVE_ENTERMSG      =  0            /* Event is enter   */
  14. EDF_DELETED       = '00000001'x   /* Event is deleted */
  15. EDF_DONE          = '00000004'x   /* Event is done    */
  16. EDF_FREEZE        = '00000020'x   /* Event is frozen  */
  17.  
  18. /* needs THOR and bbsread.library functions */
  19.  
  20. p = ' ' || address() || ' ' || show('P',,)
  21. thorport = pos(' THOR.',p)
  22.  
  23. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  24. else
  25. do
  26.     say 'No THOR port found!'
  27.     exit 10
  28. end
  29.  
  30. if ~show('p', 'BBSREAD') then do
  31.     address command
  32.     "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  33.     "WaitForPort BBSREAD"
  34.     end
  35.  
  36. /* get current BBS selected event number */
  37.  
  38. address(thorport)
  39. CURRENTSYSTEM stem CURRENT
  40. System = CURRENT.BBSNAME
  41. drop CURRENT
  42. GETSELECTEDEVENT
  43. if(rc ~= 0) then do
  44.     address(thorport)
  45.     errstring = THOR.LASTERROR
  46.     if rc = 5 then errstring = 'Event window not open'
  47.     REQUESTNOTIFY '"'errstring'"' '"Abort"'
  48.     exit
  49.     end
  50.  
  51.  
  52. /* Get event details */
  53.  
  54. EventNo = result
  55. address(bbsread)
  56. READBREVENT '"'System'"' eventnr EventNo datastem EVENTDATA tagsstem EVENTTAGS
  57. if(rc ~= 0) then call BBSError()
  58.  
  59. /* Make sure it is an EMail event*/
  60.  
  61. if upper(EVENTTAGS.CONFERENCE) ~= 'EMAIL' then do
  62.     address(thorport)
  63.     REQUESTNOTIFY '"Selected event is not an EMail event"' '"Abort"'
  64.     exit
  65.     end
  66.  
  67. /* Make sure it is an Enter event*/
  68.  
  69. if EVENTDATA.EVENTTYPE ~= EVE_ENTERMSG then do
  70.     address(thorport)
  71.     REQUESTNOTIFY '"Selected event is not an Enter event"' '"Abort"'
  72.     exit
  73.     end
  74.  
  75. /* Get string to match comment field on */
  76.  
  77. address(thorport)
  78. REQUESTSTRING TITLE '"Comment string"' BT '"_OK|_Cancel"' BODY '"Enter string to search for\nin User Database Comments"' ID '"'EVENTTAGS.TOADDR'"'
  79. MatchString = result
  80. if(rc ~= 0) then do
  81.     address(thorport)
  82.     if (rc ~= 5) then REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Abort"'
  83.     exit
  84.     end
  85.  
  86. /* Search User Database for matches */
  87.  
  88. address(bbsread)
  89. SEARCHBRUSER '"'System'"' STEM SearchResult SEARCH '"#?'MatchString'#?"' COMMENT
  90. if(rc ~= 0) then call BBSError()
  91.  
  92. if SearchResult.COUNT = 0 then do
  93.     address(thorport)
  94.     REQUESTNOTIFY '"No matches for' MatchString 'found in User database"' '"OK"'
  95.     exit
  96.     end
  97.  
  98. address(thorport)
  99. REQUESTNOTIFY '"'SearchResult.COUNT 'matches found"' '"_OK|_Cancel"'
  100. if (result ~= 1) then exit
  101.  
  102. /* Read addresses from User Database */
  103.  
  104. address(bbsread)
  105. do User = 1 to SearchResult.COUNT
  106.     UserNo = SearchResult.User.USERNR
  107.     READBRUSER BBSNAME '"'System'"' USERNR SearchResult.User.USERNR TAGSSTEM USERTAGS
  108.     if(rc ~= 0) then call BBSError()
  109.  
  110.     /* Replace address with that from database and write event */
  111.  
  112.     EVENTTAGS.TOADDR = USERTAGS.ADDRESS
  113.     WRITEBREVENT BBSNAME '"'System'"' EVENT EVE_ENTERMSG STEM EVENTTAGS
  114.     if(rc ~= 0) then call BBSError()
  115.     end
  116.  
  117.  
  118. address(thorport)
  119. REQUESTNOTIFY '"'User-1 'Email events created\nDelete original event?"' '"_Yes|_No"'
  120. if (result = 1) then do
  121.     address(bbsread)
  122.     UPDATEBREVENT bbsname '"'System'"' eventnr EventNo SETDELETED
  123.     end
  124.  
  125. exit
  126.  
  127. /*==================================================================================*/
  128.  
  129. BBSError:
  130.     address(thorport)
  131.     REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Abort"'
  132.     exit
  133.  
  134.